import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;


public class BeanExtractor {
	Object o = null;
	
	public BeanExtractor (Object o){
		this.o = o;
	}

	void printBean (){
		Method methodsList[] = o.getClass().getMethods();
		
		for(int i=0;i<methodsList.length;i++){
			String methodName = methodsList[i].getName().substring(3);
			
			if(methodsList[i].getName().startsWith("get") && !(methodsList[i].getName().startsWith("getClass")))
				try {
					System.out.println(methodName + " = " + methodsList[i].invoke(o));
				} catch (IllegalArgumentException e) {
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				} catch (InvocationTargetException e) {
					e.printStackTrace();
				}
		}
	}
}
